<?php
/**
 * Created by JetBrains PhpStorm.
 * User:Mihail Markitan
 * Date: 10/30/11
 * Time: 9:47 PM
 */
?>


<div class="form">
    <?php $form = $this->beginWidget('CActiveForm', array(
                                                         'id' => 'invoice-form',
                                                         'enableAjaxValidation' => false,
                                                    )); ?>


    <div class="row">
        <table style=" width: 755px;">
            <tr>
                <td style=" width: 363px;">
                    <?php echo $form->labelEx($model, 'billloc', array('style' => 'width: 100px;')); ?>
    <?php     $customer = Customers::model()->findByPk($model->custno);

                    $data = $model->getBillToList($location->custno);
                    echo $form->dropDownList($model, 'billloc', $data);
                    echo $form->error($model, 'billloc');
                   ?> <br clear="all">

                     <span id='billadd1' style="margin-left: 100px;"></span><br/>
                   <span id='billadd2' style="margin-left: 100px;"></span><br/>
                    <span id='billcsz' style="margin-left: 100px;"></span><br/>
                </td>
                <td >

                    <span style=" display: block;
                                  float: left;
                                  font-size: 1em;
                                  font-weight: bold;
                                  margin-top: 3px;
                                 padding: 3px;
                                 padding-bottom: 10px;">
                        Ship to:  <?="$model->shipname"?></span>
                        <br clear="all"/>
                     <?=$model->shipaddress1?><br/>
                    <?=  $model->shipaddress2?><br/>
                    <?=$model->shipCSZ?><br/>
                </td>

            </tr>
        </table>

    </div>
      <br clear="both">  <br clear="both"> <br clear="both">
    <div class="row">
        <?php echo $form->labelEx($model, 'invoice', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php echo $form->textField($model, 'invoice'); ?>
        <?php echo $form->error($model, 'invoice'); ?>
        <?php echo $form->labelEx($model, 'agreementno', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php echo $form->dropDownList($model, 'agreementno', array(1 => 'Test', 2 => 'Test2')); ?>
        <?php echo $form->error($model, 'agreementno'); ?>

    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'invoicedate', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php if($model->isNewRecord): ?>
        <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                                                   'model' => $model,
                                                                   'attribute' => 'invoicedate',
                                                                   'value' => CTimestamp::formatDate('m-d-Y', $model->invoicedate),
                                                                   'options' => array('dateFormat' => 'm-d-yy'),
                                                              ));
        ?>
        <?php else: ?>
        <div class="model-data"><?=$model->invoicedate?></div>
        <?php endif; ?>
        <?php echo $form->error($model, 'invoicedate'); ?>

        <?php echo $form->labelEx($model, 'pricecode', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php echo $form->dropDownList($model, 'pricecode', array('A'=>'A','B'=>'B','C'=>'C')); ?>
        <?php echo $form->error($model, 'pricecode'); ?>

     </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'department', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php
        $data = $model->getDepartments();
        echo $form->dropDownList($model, 'department',$data);
        ?>
        <?php echo $form->error($model, 'department'); ?>

        <?php echo $form->labelEx($model, 'salesperson', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php
        $data =Customers::model()->getSalePersonList();
        echo $form->dropDownList($model, 'salesperson',$data);
        ?>
        <?php echo $form->error($model, 'salesperson'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'taxcode', array('style' => 'width: 100px; white-space: nowrap;')); ?>
        <?php echo $form->dropDownList($model, 'taxcode', $model::model()->getTaxCodeList()); ?>
        <?php echo $form->error($model, 'taxcode'); ?>

        <?php echo CHtml::label('Created by', 'crby', array('style' => 'width: 100px;')); ?>
        <?php echo CHtml::textField('crby',Yii::app()->user->name) ?>
    </div>
    <div class="row">
        <?php echo CHtml::label('Job', 'job', array('style' => 'width: 100px;')); ?>
        <?php echo CHtml::dropDownList('job', 1, array(0 => 'test0', 1 => 'test1')) ?>

        <?php echo $form->labelEx($model, 'slterms', array('style' => 'width: 100px; white')); ?>
        <?php echo $form->dropDownList($model, 'slterms', Customers::model()->getTermList()); ?>
        <?php echo $form->error($model, 'slterms'); ?>



    </div>
    <div class="row">
        <?php echo CHtml::label('Customer PO', 'inv', array('style' => 'width: 100px;')); ?>
        <?php echo CHtml::textField('inv'); ?>

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create Invoice' : 'Save',array('align'=>'left')); ?>

    </div>


   
    <br/>


 <br clear="both">
    <div id="customer-tab">
        

    </div>
    <div class="row">
       
    </div>

    <?php $this->endWidget(); ?>
</div>
 
